From: Keir Fraser Date: Fri, 28 Dec 2007 15:23:28 +0000 (+0000) Subject: In C99 (7.19.6.2.10), the behavior of scanf("stuff... %n", ..., &n) is X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~14445^2~85 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=8f8a3b56592acf31ffcbf6b6747e247dd53da355;p=xen.git In C99 (7.19.6.2.10), the behavior of scanf("stuff... %n", ..., &n) is said to be undefined if the value to be put is n can't fit. I guess we can safely consider that the same applies to printf. Signed-off-by: Samuel Thibault --- diff --git a/extras/mini-os/lib/printf.c b/extras/mini-os/lib/printf.c index 676f4e74a1..a6767e48ad 100644 --- a/extras/mini-os/lib/printf.c +++ b/extras/mini-os/lib/printf.c @@ -426,8 +426,6 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args) case 'n': - /* FIXME: - * What does C99 say about the overflow case here? */ if (qualifier == 'l') { long * ip = va_arg(args, long *); *ip = (str - buf); @@ -446,7 +444,7 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args) ++str; continue; - /* integer number formats - set up the flags and "break" */ + /* integer number formats - set up the flags and "break" */ case 'o': base = 8; break; diff --git a/xen/common/vsprintf.c b/xen/common/vsprintf.c index 7c2d5057e2..5ee5f4efce 100644 --- a/xen/common/vsprintf.c +++ b/xen/common/vsprintf.c @@ -404,8 +404,6 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args) case 'n': - /* FIXME: - * What does C99 say about the overflow case here? */ if (qualifier == 'l') { long * ip = va_arg(args, long *); *ip = (str - buf); @@ -424,7 +422,7 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args) ++str; continue; - /* integer number formats - set up the flags and "break" */ + /* integer number formats - set up the flags and "break" */ case 'o': base = 8; break;